#ifndef PARSE_H
#define PARSE_H

typedef struct n node;

typedef struct
{
	float3 normal;
	float3 point;
	node *n;
} vertex;

typedef struct tri
{
	float3 points[3];
	float3 normal;
	float3 normals[3];
	int sf_id;
	vertex *ps[3];
} tri;

struct n
{
	tri *t;
	node *next;
};

void make_matrix4(float4 (&m)[4], float x, float y, float z)
{
	m[0].x =  cos(z) * cos(y);
	m[0].y = -cos(y) * sin(z);
	m[0].z =  sin(y);
	m[1].x =  cos(x) * sin(z) + sin(x) * sin(y) * cos(z);
	m[1].y =  cos(x) * cos(z) - sin(x) * sin(y) * sin(z);
	m[1].z = -cos(y) * sin(x);
	m[2].x =  sin(x) * sin(z) - cos(x) * cos(z) * sin(y);
	m[2].y =  cos(x) * sin(y) * sin(z) + cos(z) * sin(x);
	m[2].z =  cos(y) * cos(x);
	m[3].x = 0;
	m[3].y = 0;
	m[3].z = 0;
	m[3].w = 1;
}

int nstrlen(const char *str)
{
	int length = 0;
	while(str[length] != '\n' || str[length] != '\0')
		length++;
	
	return length;
}

int nstrcmp(const char *str1, const char *str2)
{
	for(int n = 0; str2[n] != '\n' || str2[n] != '\0' || str2[n] != ' ' ; n++)
	{
		if(str1[n] == '\0')
			return 0;
		
		if(str1[n] != str2[n])
			return 1;
		
	}
	
	return 1;
}

char *Fgets(char *str, int num, FILE *stream)
{
	char *result = fgets(str, num, stream);
	if(!result)
	{
	printf("oh noes!\n");
	exit(1);
	}
}

#endif
